package com.handl.springcloud.controller;

import com.handl.springcloud.dto.User;
import com.handl.springcloud.servie.UserServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by handl on 2017/11/6.
 */
@RestController
public class UserController {

    @Autowired
    private UserServiceFeign userServiceFeign;

    /***  通过抽象抽离接口调用 ****/
    @RequestMapping("httpp")
    public String getHttpP(){
        return userServiceFeign.getHttpParam("da tan");
    }
    @RequestMapping("httph")
    public String getHttpH(){
        return userServiceFeign.getHttpHeard("wo hen niu");
    }
    @RequestMapping("httpb")
    public String getHttpB(){
        User user = new User();
        user.setName("shi er lou!");
        user.setAge(89);
        user = userServiceFeign.getHttpBody(user);
        return user.getName()+","+user.getAge();
    }

    /****  自定义调用服务提供者  ****/
    @RequestMapping("self1")
    public String self1(){
        return userServiceFeign.self1("self da tang ");
    }
    @RequestMapping("self2")
    public String self2(){
        return userServiceFeign.self2("self wo hen niu bi");
    }
    @RequestMapping("self3")
    public String self3(){
        User user = new User();
        user.setName("self shi er lou");
        user.setAge(109);
        user = userServiceFeign.self3(user);
        return user.getName()+","+user.getAge();
    }

}
